package com.legoo.studaychineseonline.activity;


import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.legoo.studaychineseonline.R;
import com.legoo.studaychineseonline.base.BaseActivity;
import com.legoo.studaychineseonline.fragment.LoginFragment;
import com.legoo.studaychineseonline.fragment.RegisterFragment;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;


/**
 * 类描述:
 * 创建人:J R   on 2018/8/28 09:54
 * 修改人:
 * 修改时间:
 * 修改说明;
 */
public class LoginActivity extends BaseActivity {


    @BindView(R.id.tv_title_left)
    TextView tvTitleLeft;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.tv_title_right)
    TextView tvTitleRight;
    @BindView(R.id.tv_login)
    TextView tvLogin;
    @BindView(R.id.v_login)
    View vLogin;
    @BindView(R.id.ll_login)
    LinearLayout llLogin;
    @BindView(R.id.view)
    View view;
    @BindView(R.id.tv_register)
    TextView tvRegister;
    @BindView(R.id.v_register)
    View vRegister;
    @BindView(R.id.ll_register)
    LinearLayout llRegister;
    @BindView(R.id.fragment_notify)
    FrameLayout fragmentNotify;
    String number = "";

    @Override
    protected void myOnCreate(@Nullable Bundle savedInstanceState) {
        ButterKnife.bind(this);
        tvTitle.setText("");
        tvTitleRight.setVisibility(View.INVISIBLE);
        tvTitleLeft.setBackgroundResource(R.mipmap.img_fanhui);
        FragmentManager fragmentManager = getSupportFragmentManager();
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        Fragment   fragment = new LoginFragment();
        if (number!=null&&!"".equals(number)){
            Bundle bundle = new Bundle();
            bundle.putString("iphoneNumber",number);
            fragment.setArguments(bundle);
        }
        fragmentTransaction.replace(R.id.fragment_notify, fragment, LoginFragment.class.getName());
        fragmentTransaction.commitAllowingStateLoss();
    }

    @Override
    public void initData() {

    }

    @Override
    protected void resolveBundle(Bundle bundle) {

    }

    @Override
    protected int myLayoutId() {
        return R.layout.activity_login;
    }


    @OnClick({R.id.tv_title_left, R.id.ll_login, R.id.ll_register})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_title_left:
                finish();
                break;
            case R.id.ll_login:
                tvLogin.setTextColor(Color.parseColor("#d5141f"));
                vLogin.setBackgroundColor(Color.parseColor("#d5141f"));
                tvRegister.setTextColor(Color.parseColor("#888888"));
                vRegister.setBackgroundColor(Color.parseColor("#888888"));
                FragmentManager fragmentManager = getSupportFragmentManager();
                FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

                Fragment  fragment = new LoginFragment();

                if (number!=null&&!"".equals(number)){
                    Bundle bundle = new Bundle();
                    bundle.putString("iphoneNumber",number);
                    fragment.setArguments(bundle);
                }

                fragmentTransaction.replace(R.id.fragment_notify, fragment, LoginFragment.class.getName());
                fragmentTransaction.commitAllowingStateLoss();
                break;
            case R.id.ll_register:
                tvLogin.setTextColor(Color.parseColor("#888888"));
                vLogin.setBackgroundColor(Color.parseColor("#888888"));
                tvRegister.setTextColor(Color.parseColor("#d5141f"));
                vRegister.setBackgroundColor(Color.parseColor("#d5141f"));
                FragmentManager fragmentManager2 = getSupportFragmentManager();
                FragmentTransaction fragmentTransaction2 = fragmentManager2.beginTransaction();
                Fragment    fragment2 = new RegisterFragment();
                fragmentTransaction2.replace(R.id.fragment_notify, fragment2, LoginFragment.class.getName());
                fragmentTransaction2.commitAllowingStateLoss();
                break;
                default:
        }
    }
    public void  clickLogin(String number){
        this.number = number;
            llLogin.callOnClick();
    }
}
